package com.globalwave.rule.engine;

import java.util.Map;

import com.globalwave.rule.entity.RuleAction;

public class ResultAction {

	/**
	 * 变量因子
	 */
    private Factor varFactor ;
    /**
     * 取值因子
     */
    private Factor valueFactor ;
    
    public ResultAction(RuleAction action) {
    	varFactor = 
    		new Factor(
    				action.getVar_property(), 
    				action.getVar_convertor(), 
    				null, 
    				action.getType_()) ;

    	valueFactor = 
    		new Factor(
    				action.getValue_property(), 
    				action.getValue_convertor(), 
    				action.getValue_value(), 
    				action.getType_()) ;
    }
    
    public void handle(Map<String, Object> vars) throws Exception {
    	varFactor.setValue(vars, valueFactor.getValue(vars)) ;
    }
}
